package edu.winona.csclub.testing.gui;

import java.awt.Component;

import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

import edu.winona.csclub.testing.core.TestCase;

public class TestCaseListCellRenderer extends JLabel implements ListCellRenderer {

	
    public TestCaseListCellRenderer() {
        setOpaque(true);
    }
	
	public Component getListCellRendererComponent(JList list, Object value,
			int index, boolean isSelected, boolean cellHasFocus) {
			
	      if (isSelected) {
	            setBackground(list.getSelectionBackground());
	            setForeground(list.getSelectionForeground());
	        } else {
	            setBackground(list.getBackground());
	            setForeground(list.getForeground());
	        }
		if(! (value instanceof String ))
	      setText( ( (TestCase)value ).getName());
		else
			setText("                                  ");
		return this;
	}

}
